import {TronAPI} from "./api-tron"
import {ContractTokenConfig} from "./contract-token-config"
const TronAPI_Token = {
  triggerContract: function(method, args, feeLimit, callValue) {
    return TronAPI.triggerContract(
      ContractTokenConfig.contractAddress,
      ContractTokenConfig.contractAbi,
      method, args, feeLimit, callValue
    )
  },
  //查询账户余额(Token)
  balanceOf: function(addr) {
    return this.triggerContract("balanceOf", [addr], 1e8, 0)
  },
  //参与认筹
  bet: function(trxAmount, inviteCode) {
    return this.triggerContract("bet", [inviteCode], 1e8, trxAmount*1000000)
  },
  //认筹结算
  settle: function(date, betAccount) {
    return this.triggerContract("settle", [date, betAccount], 1e8, 0)
  },
  //查询日汇率
  getDayCurrency: function(year, month, date) {
    return this.triggerContract("getDayCurrency", [year, month, date], 1e8, 0)
  },
  //查询日汇率(闪兑之用)
  getExchangeDayCurrency: function() {
    return this.triggerContract("getExchangeDayCurrency", [], 1e8, 0)
  },
  //查询月汇率
  getMonthCurrency: function(year, month) {
    return this.triggerContract("getMonthCurrency", [year, month], 1e8, 0)
  },
  //查询月汇率(闪兑之用)
  getExchangeMonthCurrency: function() {
    return this.triggerContract("getExchangeMonthCurrency", [], 1e8, 0)
  },
  //获取总认筹额
  getTotalBetAmount() {
    return this.triggerContract("getTotalBetAmount", [], 1e8, 0)
  },
  //设置闪兑合约地址
  setExchangeContract(exchangeContractAddr) {
    this.triggerContract("setExchangeContract", [exchangeContractAddr], 1e8, 0)
  },
  getExchangeContract() {
    return this.triggerContract("getExchangeContract", [], 1e8, 0)
  },
  getDayBetAmount(betDate, betAccount) {
    return this.triggerContract("getDayBetAmount", [betDate, betAccount], 1e8, 0)
  },
  getLastDay() {
    return this.triggerContract("getLastDate", [], 1e8, 0)
  },
  getFoundationAccount() {
    return this.triggerContract("getFoundationAccount", [], 1e8, 0)
  },
  getProjectSideAccount() {
    return this.triggerContract("getProjectSideAccount", [], 1e8, 0)
  },
}

export {
  TronAPI_Token
}